# -*- coding: utf-8 -*-

# *args 将一个非键值对的可变参数列表传给方法
def test_var_args (f_arg, *args):
    print("normal arg: ", f_arg)
    for arg in args:
        print("another arg through *argv:", arg)

test_var_args('yasoob', 'python', 'eggs', 'test')

# **kwargs 讲一个 可边长 键值 参数列表传给方法
def test_var_kwargs (**kwargs):
    for key, value in kwargs.items():
        print("{0} == {1}".format(key, value))

test_var_kwargs(name="yang", age=18)

def test_args_kwargs(arg1, arg2, arg3):
    print("arg1", arg1)
    print("arg2", arg2)
    print("arg3", arg3)

args = ("two", 2, 3)
test_args_kwargs(*args)
kargs = {"arg3": 3, "arg1": 1, "arg2":5}
test_args_kwargs(**kargs)

# 同时在方法中包含 两种 传参方式
def demo_args_kwargs(f_flag, *args, **kwargs):
    print("normal args is :", f_flag)
    for arg in args:
        print("arg value is {0}".format(arg))
    for key,val in kwargs.items():
        print("kwarg key is {0} value is {1}".format(key, val))

demo_args_kwargs("12", "two",2, 3, arg4="asfdaf", arg5="adfadfasdfasdf")

a = 1 if 2 > 3 else 3
print(a)

b = [x * x for x in range(1, 10, 2)]
print(b)

some_list = ['a', 'b', 'c', 'b', 'd', 'm', 'n', 'n']
duplicates = []
for val in some_list:
    if some_list.count(val) > 1:
        if val not in duplicates:
            duplicates.append(val)


print("duplicates value are: ", duplicates)

duplicates = set([x for x in some_list if some_list.count(x) > 1])
print("set vaule is :", duplicates)

# 交集
valid = set(['yellow', 'red', 'blue', 'green', 'black'])
input_set = set(['red', 'brown'])
print("交集", valid.intersection(input_set))
print("差集", valid.difference(input_set))
print("并集", valid.union(input_set))

def hi(name = "hello"):
    return "hi {0}".format(name)

greet = hi

print(greet(), id(greet), id(hi))
# del hi

# print(hi())
